<script setup lang="ts">
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: 0,
    role_name: "",
    role_code: "",
    allow_auth: [],
    status: 1,
    rank: 10,
    remark: "????"
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-form-item label="角色名称" prop="role_name">
      <el-input
        v-model="newFormInline.role_name"
        clearable
        placeholder="请输入角色名称"
      />
    </el-form-item>

    <el-form-item label="角色标识" prop="role_code">
      <el-input
        v-model="newFormInline.role_code"
        clearable
        placeholder="请输入角色标识"
      />
    </el-form-item>

    <el-form-item label="角色排序" prop="rank">
      <el-input v-model="newFormInline.rank" clearable type="number" />
    </el-form-item>

    <el-form-item label="备注">
      <el-input
        v-model="newFormInline.remark"
        placeholder="请输入备注信息"
        type="textarea"
      />
    </el-form-item>
  </el-form>
</template>
